package com.tj.jinzao.presenter;


import com.tj.jinzao.api.SubscriberCallBack;
import com.tj.jinzao.base.BasePresenter;
import com.tj.jinzao.base.IBaseView;
import com.tj.jinzao.model.Goods;
import com.tj.jinzao.model.ResultResponse;

import java.util.List;

/**
 * 商品处理
 * Created by wjy 2018/12/10.
 */
public class GoodsPresenter extends BasePresenter<IBaseView<List<Goods>>> {

    public GoodsPresenter(IBaseView<List<Goods>> view) {
        super(view);
    }

    public void getGoodsList() {
        addSubscription(mApiService.getGoodsList()
                , new SubscriberCallBack<List<Goods>>(mView.getContext()) {
                    @Override
                    protected void onSuccess(List<Goods> list) {
                        if (mView != null) mView.onRequestSuccess(list);
                    }

                    @Override
                    protected void onFailure(ResultResponse response) {
                        if (mView != null) mView.onRequestError(response.getMessage());
                    }

                    @Override
                    protected boolean isShowProgress() {
                        return true;
                    }
                });
    }

}